import {
  ReservationOrderRespVO,
  VenueSearchVO,
  ReservationCmd,
  SearchPageQry,
} from '@/service/reservation/type'
import { http } from '@/utils/http'
import type { PageQry, PageVO } from '@/typings'

export const pageSearchVenue = async (
  searchPageQry: SearchPageQry = {
    keyword: '',
    current: 1,
    size: 12,
  },
) => {
  return http<PageVO<VenueSearchVO>>({
    url: '/vrs/venue/search/page',
    method: 'GET',
    query: searchPageQry,
  })
}

export const getFieldDetail = async (id: string) => {
  return http<VenueSearchVO>({
    url: `/vrs/venue/detail`,
    method: 'GET',
    query: { id },
  })
}

export const postReservation = async (cmd: ReservationCmd) => {
  return http<string>({
    url: '/vrs/order/reservation',
    method: 'POST',
    data: cmd,
  })
}

export const getHistory = async (
  page: PageQry = {
    current: 0,
    size: 10,
  },
) => {
  return http<PageVO<ReservationOrderRespVO>>({
    url: '/vrs/order/reservation/history',
    method: 'GET',
    query: page,
  })
}
